;;(load "ut.scm")
;;(load "err-ut.scm")
;;(load "cod.scm")
;;(load "num.scm")
(def/err (get-符号 s m n st)
  (let* ((len (string-length s))
         (c (if (< n len)(string-ref s n)))
         )
    (cond
      ((or (>= n len)(rd-all-deli c))
       (if (or (eq? st '整数)(eq? st '小数)(eq? st '分数)(eq? st '指数数)(eq? st '词语))
           (list (substring s m n) (- n 1) st)
	   (begin
	     ;;(err-msg "错误信息[get-符号][~a]：[~a]不是可用数值或标识符状态。" n st)
	     (list 'err (- n 1) st '非法常量 "非法符号状态。"))))
      ((and (eq? st '开始)(or (rd-digit c)(rd-正负号 c)))
       (let* ((res (get-数值 s m n st))(str (nth 0 res))(i (nth 1 res))(st (nth 2 res)))
	 (if (eq? str 'err)
	     (get-符号 s m (+ n i 1) '词语)
	     (get-符号 s m (+ n i 1) st))))
      (else (set! st '词语)
            (get-符号 s m (+ n 1) st)))))
(def/err (get-sym s n)
  (let* ((res (run/err get-符号 s n n '开始))(str (nth 0 res))(i (nth 1 res))(st (nth 2 res)))
    (cond
     ((eq? st '词语)
      (if (or (= n 0)(and (> n 0)(rd-p-deli (string-ref s (- n 1)))))
	  (let* ((res1 (run/err find-system-dict-key-coding-list str))(cur-st (car res1))(coding (cadr res1)))
	    (if (not cur-st)
		(begin
		  (set! res1 (run/err find-dict-coding-list str 'system))
		  (set! cur-st (car res1))
		  (set! coding (cadr res1))
		  (if (and cur-st (eq? cur-st '系统宏))
		      (list str i cur-st coding)
		      (list str i '词语 '())))
		(list str i '系统关键字 coding))
	    )
	  (list str i '词语 '())))
      (else (list str i st '())))))
(def/err (get-sym-or-num s n)(run/err get-符号 s n n '开始))

